package cn.siat.gene.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.fasterxml.jackson.annotation.JsonFormat;
import cn.siat.common.core.annotation.Excel;
import cn.siat.common.core.utils.StringUtils;
import cn.siat.gene.model.Annotation;
import cn.siat.gene.model.AnnotationTypeHandle;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;

import javax.json.Json;
import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 方案信息
 * @Author: Administrator
 * @Date: 2022-10-22
 * @Version: V1.0
 */
@Data
@TableName(value = "programme",autoResultMap = true)
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value = "programme对象", description = "方案信息")
public class Programme implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 主键
     */
    @TableId(type = IdType.ASSIGN_ID)
    @ApiModelProperty(value = "主键")
    private String id;
    /**
     * 创建人
     */
    @Excel(name = "创建人", width = 15)
    @ApiModelProperty(value = "创建人")
    private String createStaffNo;
    /**
     * 创建日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建日期")
    private Date createTime;
    /**
     * 更新人
     */
    @Excel(name = "更新人", width = 15)
    @ApiModelProperty(value = "更新人")
    private String updateStaffNo;
    /**
     * 更新日期
     */
    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "更新日期")
    private Date updateTime;
    /**
     * 方案名称
     */
    @Excel(name = "方案名称", width = 15)
    @ApiModelProperty(value = "方案名称")
    private String programmeName;
    /**
     * 方案编号
     */
    @Excel(name = "方案编号", width = 15)
    @ApiModelProperty(value = "方案编号")
    private String programmeNumber;

    /**
     * 方案状态
     */
    @Excel(name = "方案状态", width = 15)
    @ApiModelProperty(value = "方案状态")
    private String programmeExamineState;

    /**
     * 方案状态 0 仅查看 1 可编辑
     */
    @Excel(name = "方案状态 0 仅查看 1 可编辑", width = 15)
    @ApiModelProperty(value = "方案状态 0 仅查看 1 可编辑")
    private Integer programmeState;
    /**
     * 方案状态标识
     */
    @Excel(name = "方案状态标识", width = 15)
    @ApiModelProperty(value = "方案状态标识")
    private String stateId;

    /**

     * 配置文件标识
     */
    @Excel(name = "配置文件标识", width = 15)
    @ApiModelProperty(value = "配置文件标识")
    private String configFileId;

    @Excel(name = "所属人", width = 15)
    @ApiModelProperty(value = "所属人")
    private String possessStaff;
    /**
     * 打包状态:0已打包；1未打包
     */
    @Excel(name = "打包状态:0已打包；1未打包", width = 15)
    @ApiModelProperty(value = "打包状态:0已打包；1未打包")
    private Integer packState;

    /**
     * 项目id
     */
    @Excel(name = "项目id", width = 15)
    @ApiModelProperty(value = "项目id")
    private String projectId;

    /**
     * 创建员工昵称
     */
    @Excel(name = "创建员工昵称", width = 15)
    @ApiModelProperty(value = "创建员工昵称")
    private String createStaffName;
    //排序字段
    @TableField(exist = false)
    private String orderByColumn;
    //
    @TableField(exist = false)
    private String isAsc;

    @TableField(typeHandler = AnnotationTypeHandle.class)
    private List<Annotation> annotationList;

    /**
     * 根据方案打包状态筛选
     */
    @TableField(exist = false)
    private String[] packStates;

    @TableField(exist = false)
    private String templateId;

    /**
     * 最后浏览时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone ="GMT+8")
    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
    private Date viewedTime;

    private String sourceFileName;
    private String packFileName;
    private String sourceFileMergeName;
    @TableField(exist = false)
    private String sourceFileNameShow;
    private Boolean saveFeature;
    public String getSourceFileNameShow(){
        if(StringUtils.isNotEmpty(sourceFileName)){
            String[] strs = sourceFileName.split(",");
            StringBuilder sb = new StringBuilder();
            for (String str : strs) {
                int index = str.indexOf("-");
                if(index>-1){
                    sb.append(str.substring(index+1));
                }else{
                    sb.append(str);
                }
                sb.append(", ");
            }
            sb.delete(sb.length()-2,sb.length()-1);
            return sb.toString();
        }
        return "";
    }
    /**
     * 载体
     */
    @Excel(name = "载体", width = 15)
    @ApiModelProperty(value = "载体")
    private String carrier;
    /**
     * 载体
     */
    @Excel(name = "注释用数据库", width = 15)
    @ApiModelProperty(value = "注释用数据库")
    private String databaseForAnnotation;

    private String packType;
    private Integer chooseFile;
    @TableField(exist = false)
    private List<Sequence> sequenceList;
    private Integer maxFeaturesToShow;
    public int getMaxFeaturesToShowNoNull(){
        return maxFeaturesToShow==null?50:maxFeaturesToShow;
    }
    private Integer sequenceLengthToShow;
    //关联分子方案打包
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String,Map<String,String>> molecularPack;

    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<String,String> runningState;
    private Integer lastSequenceId;
    private Integer analyseState;
    private String designProjectId;
}
